package com.yc.yyds.dao;

import com.yc.yyds.util.DBHelper;

import java.util.List;
import java.util.Map;

public class DanmuDao {

    //查询弹幕
    public List<Map<String,Object>> query(String movied){
        String sql ="select id,d.userid,username,d.time,image,content from danmu d inner join user u on d.userid=u.userid where movieid=?";
        return DBHelper.selectListMap(sql,movied);
    }
    //保存弹幕
    public void  save(String userid,String movieid,String content){
        String sql = " insert into danmu(userid,movieid,content) values (?,?,?)";
        DBHelper.update(sql,userid,movieid,content);
    }
    public long num(String movieid){
        String sql = " select 1 from danmu where movieid = ?";
        return DBHelper.count(sql,movieid);
    }
}
